package com.woniu.controller;


import com.woniu.service.ICourseService;
import com.woniu.vo.NewCourseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@RequestMapping("/index")
@Controller
public class IndexController {

    @Autowired
    ICourseService courseService;

    @Value("${params.index.newCourseNum}")
    private Integer newCourseNum;

    @Value("${params.index.hotCourseNum}")
    private Integer hotCourseNum;




    @GetMapping
    public String toCouseIndex(Model model){

       List<NewCourseVO>  newCourseVOList = courseService.queryNewCourse(newCourseNum);
       List<NewCourseVO>  hotCourseVOList = courseService.queryHotCourse(hotCourseNum);

       model.addAttribute("newCourseVOList",newCourseVOList);
       model.addAttribute("hotCourseVOList",hotCourseVOList);

       return "index";

    }


}
